package main

import (
	"os"
	"os/exec"

	"github.com/spf13/cobra"
)

// 执行获取物理磁盘列表命令

func runMegacliGetPdList(cmd *cobra.Command, args []string) error {
	toolPath, err := extractTool("tools/MegaCli64")
	if err != nil {
		return err
	}

	megacliCmd := exec.Command(toolPath, "-PDList", "-aALL")
	megacliCmd.Stdin = os.Stdin
	megacliCmd.Stdout = os.Stdout
	megacliCmd.Stderr = os.Stderr

	return megacliCmd.Run()
}

// 执行获取逻辑磁盘列表命令
func runMegacliGetLdList(cmd *cobra.Command, args []string) error {
	toolPath, err := extractTool("tools/MegaCli64")
	if err != nil {
		return err
	}

	megacliCmd := exec.Command(toolPath, "-LDInfo", "-Lall", "-aALL")
	megacliCmd.Stdin = os.Stdin
	megacliCmd.Stdout = os.Stdout
	megacliCmd.Stderr = os.Stderr

	return megacliCmd.Run()
}
